package com.minstone.common.util;

import java.util.HashMap;
import java.util.Map;

public class ResultPage {

	private int pageRowNum;
	private int currPage;
	private long totalPage;
	private long totalRow;
	private int pageIndex;

	public int getPageRowNum() {
		return pageRowNum;
	}

	public void setPageRowNum(int pageRowNum) {
		this.pageRowNum = pageRowNum;
	}

	public int getCurrPage() {
		return currPage;
	}

	public void setCurrPage(int currPage) {
		this.currPage = currPage;
	}

	public long getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(long totalPage) {
		this.totalPage = totalPage;
	}

	public long getTotalRow() {
		return totalRow;
	}

	public void setTotalRow(long totalRow) {
		this.totalRow = totalRow;
	}

	public int getPageIndex() {
		return pageIndex;
	}

	public void setPageIndex(int pageIndex) {
		this.pageIndex = pageIndex;
	}

	/**
	 * 封装分页数据
	 * @param pageRowNum
	 * @param pageIndex
	 * @param totalRow
	 * @param dataList
	 * @return
	 */
	public static Map getPageData(int pageRowNum, int pageIndex, long totalRow, Object dataList) {
		Map<String, Object> pageMap = new HashMap<String, Object>();

		ResultPage pageObj = new ResultPage();
		pageObj.setTotalRow(totalRow);
		pageObj.setCurrPage(pageIndex);
		pageObj.setPageIndex(pageIndex);
		pageObj.setPageRowNum(pageRowNum);
		pageObj.setTotalPage(totalRow / pageRowNum + (totalRow % pageRowNum == 0 ? 0 : 1));

		pageMap.put("pageObj", pageObj);
		pageMap.put("dataList", dataList);

		return pageMap;
	}

}
